/*
i【例1】设计一个抽象类Shape，它表示具有形状的东西，并体现了抽象的概念，
	在它下面可以派生出多种具体形状，比如三角形、矩形等。
*/

#include <iostream>
using namespace std;

class Shape {
	protected:
		double x, y;

	public:
	void set(double i, double j){
		x = i;
		y = j; 
		}
	virtual void area() = 0;
};

class Triangle: public Shape {
	public:
		void area() {
			cout << "Triangle Area: " << 0.58 * x * y << endl;
		}
};

class Rectangle: public Shape {
	public:
		void area() {
			cout << "Rectangle Area: " << x * y << endl;
		}
};

int main(int argc, char * argv[]) {
	Shape * p;
	Triangle t;
	Rectangle r;

	p = &t;
	p->set(5.1, 10);
	p->area();

	p = &r;
	p->set(5.1, 10);
	p->area();

	return 0;
}
